package com.wing.productionPlan.enumeration;

import cn.hutool.core.util.ObjectUtil;

public enum PieceRateStatusEnum {
    
    TO_CONFIRM(0,"待确认"),
    CONFIRMED(1,"已确认"),
    TO_SETTLEMENT(2,"待结算"),
    SETTLEMENTED(3,"已结算");
    
    private final Integer code;
    private final String description;

    // 构造函数
    PieceRateStatusEnum(Integer code, String description) {
        this.code = code;
        this.description = description;
    }

    // Getter 方法
    public Integer getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static PieceRateStatusEnum getByCode(Integer code) {
        for (PieceRateStatusEnum status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return null;
    }

    // 可选：如果需要根据code获取description，可以提供此方法
    public static String getDescriptionByCode(Integer code) {
        PieceRateStatusEnum status = getByCode(code);
        if (ObjectUtil.isNull(status)) {
            return "";
        }
        return status.getDescription();
    }

}
